package wawi.util;

import java.io.FileInputStream;
import java.util.Properties;

public class Props
{
	private static Properties p1;
	
	static
	{
		p1 = new Properties();
		
		try
		{
			p1.load(new FileInputStream("C:\\wawi\\wawi.properties"));
		}
		catch (Exception e)
		{
			e.printStackTrace();
			System.err.println("Fehler bei Properties laden: " + e);
		}
	}
	
    private static boolean toBool (String str)
    {
        return Boolean.valueOf(str).booleanValue();
    }
    
    private static int toInt (String str)
    {
        try
        {
            return Integer.parseInt(str);
        }
        catch (NumberFormatException e)
        {
            return -1;
        }
    }
	
    public static boolean isBool (String param, boolean defau)
    {
        return toBool(p1.getProperty(param, ""+defau));
    }
    
    public static boolean isBool (String param)
    {
        return isBool(param, false);
    }
    
    public static int getInt (String param, int defau)
    {
        return toInt(p1.getProperty(param, ""+defau));
    }
    
    public static int getInt (String param)
    {
        return getInt(param, -1);
    }
    
    public static String getString(String param)
    {
        return p1.getProperty(param);
    }
    
    public static String getString(String param, String defau)
    {
        return p1.getProperty(param, defau);
    }
    
}
